<%--
 *  File:   SalesChannelEdit.jsp
 *  Desc:	
 *
 *  Date		         Author		      Changes
 *  2006-3-8	  joshli		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.BusiAreaEdit");
  String strModuleName = "COM";
  String privilegeCode = "Z0815";
%>

<%
  //get curuserinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  String strCurOrgName = (String)CurUserInfo.get("orgname");
  Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
  if(nCurOrgId == null)
  {
    nCurOrgId = new Integer(-1234567);
  }

  //get area info
  String strChannelId = (String)request.getParameter("saleschannelid");
  boolean bReadOnly = false;
  boolean bIsEdit = false;
  if(strChannelId != null)
  {
    bIsEdit = true;
    bReadOnly = true;;
  }
  else
  {
    strChannelId = "";
  }
  String strParentSalesChannelId = (String)request.getParameter("parentsaleschannelid");
  boolean bIsNewChild = true;
  if(strParentSalesChannelId == null)
  {
    bIsNewChild = false;
  }
  boolean bIsNew = !bIsEdit && !bIsNewChild;

%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="saleschanneledit"/>
<%@ include file="/inc/InitEdit.inc" %>

<%
  HashMap channelInfo = (HashMap)pageContext.getAttribute("channelinfo");
  if(channelInfo == null)
  {
    channelInfo = new HashMap();
  }
  String strParentSalesChannelName = "";
  if(bIsEdit)
  {
    strParentSalesChannelName = (String)channelInfo.get("parentsaleschannelname");
  }
  if(bIsNewChild)
  {
    strParentSalesChannelName = (String)channelInfo.get("saleschannelname");
  }
  if(strParentSalesChannelName == null)
  {
    strParentSalesChannelName = new String("");
  }
  cat.debug("The channelInfo is :" + channelInfo);
  if(!bIsEdit)
  {
    pageContext.removeAttribute("channelinfo");
  }
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<script language="JavaScript">

function page_done()
{
  	if(!checkNull(document.saleschanneleditform))
  		return;
  	emptyToNull(document.saleschanneleditform);
  document.saleschanneleditform.actionname.value = "done";
  isRunning = true;
  document.saleschanneleditform.submit();
}
</script>
</head>

<body>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="2" class="summary_top"></td>
        </tr>
        <tr>
          <td colspan="2"><img src="../../images/<%= strLanguageCode %>/quote.gif" width="16" height="11">
            <%= label.getLabelName("L_NEBusinessArea") + label.getLabelName("L_Colon") %></td>
        </tr>
      </table>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
       <form name="saleschanneleditform" method="post" action="../../Dispatcher" target="_parent">
       <input type="hidden" name="pagename" value="saleschanneledit">
       <input type="hidden" name="actionname">
       <%if(bIsEdit){%>
       <input type="hidden" name="saleschannelid" value="<%=JspHelper.filterNull( channelInfo.get("saleschannelid") )%>">
       <%}%>
       <%if(bIsNewChild){%>
       <input type="hidden" name="parentsaleschannelid" value="<%=JspHelper.filterNull( strParentSalesChannelId )%>">
       <input type="hidden" name="grade" value="<%=JspHelper.filterNull( request.getParameter("grade") )%>">
       <input type="hidden" name="isbottom" value="<%=JspHelper.filterNull( new String("Y") )%>">
       <%}%>
       <%if(bIsNew){%>
       <input type="hidden" name="grade" value="<%=JspHelper.filterNull( new Integer(1) )%>">
       <input type="hidden" name="isbottom" value="<%=JspHelper.filterNull( new String("Y") )%>">
       <%}%>

       <input type="hidden" name="orgid" value="<%=JspHelper.filterNull( nCurOrgId )%>">

       <tr>
          <td class="need" width="120"><%= label.getLabelName("L_ChannelCode") + label.getLabelName("L_Colon") %></td>
          <td>
          	<% String s = message.getMessageDesc("VALUE_NOT_NULL",  label.getLabelName("L_ChannelCode",false)); %>
            <oval:text name="channelinfo" property="saleschannelcode" size="34" readonly="<%= bIsEdit %>" isnull="N" label="<%= s %>"/>
          </td>
        </tr>

        <tr>
          <td class="need"><%= label.getLabelName("L_ChannelName") + label.getLabelName("L_Colon") %></td>
          <td>
          	<% String s1 = message.getMessageDesc("VALUE_NOT_NULL",  label.getLabelName("L_ChannelName",false)); %>
            <oval:text name="channelinfo" property="saleschannelname" size="34" isnull="N" label="<%= s1 %>"/>
          </td>
        </tr>
		<tr>
        	<td class="td-text" width="110"><%= label.getLabelName("L_Department") + label.getLabelName("L_Colon") %></td>
        	<td><custom:select optionInnerTextKey="deptname" optionsName="alldepts" optionValueKey="deptid" property="deptid" name="channelinfo" defaultValue="--------" defaultValueCost=""/></td>
        </tr>
		<%if(bIsNewChild){%>
	        <tr>
	          <td class="td-text" height="13"><%= label.getLabelName("L_ParentChannel") + label.getLabelName("L_Colon") %></td>
	          <td>&nbsp;<%=JspHelper.filterNull( strParentSalesChannelName )%>
	          </td>
	        </tr>
        <%}%> 
        
        <%if(!bIsNewChild){%>
	        <tr> 
	          <td class="td-text" height="13">&nbsp;<%= label.getLabelName("L_ParentChannel") + label.getLabelName("L_Colon") %></td>
	          <td>
			       <custom:select property="parentsaleschannelid" name="channelinfo" optionsName="allchannels"
							optionValueKey="saleschannelid" optionInnerTextKey="saleschannelname" defaultValue="--------"/>
			  </td>
	        </tr>
        <%}%>        

        </form>
      </table>
    </td>
  </tr>
  <tr>
    <td class="summary_top"></td>
  </tr>
  <tr>
    <td class="td_center"><a onclick="page_done()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a></td>
  </tr>
</table>
</body>
</html>
